	package com.xidian.GMS.controller;

	import java.text.ParseException;
	import java.text.SimpleDateFormat;
	import java.util.Date;

	import org.springframework.beans.factory.annotation.Autowired;
	import org.springframework.stereotype.Controller;
	import org.springframework.ui.Model;
	import org.springframework.web.bind.annotation.RequestMapping;
	import org.springframework.web.bind.annotation.RequestMethod;


	import com.xidian.GMS.entity.RelevantEnterprisesWebsite;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xidian.GMS.dto.Page;
import com.xidian.GMS.entity.RelevantEnterprisesWebsite;

	import com.xidian.GMS.mapper.RelevantEnterprisesWebsiteMapper;
	import com.xidian.GMS.service.RelevantEnterprisesWebsiteService;
	@Controller
public class RelevantEnterprisesWebsiteController {

		@Autowired
		  private RelevantEnterprisesWebsiteMapper RelevantEnterprisesWebsiteMapper;
		@Autowired
		 private RelevantEnterprisesWebsiteService  RelevantEnterprisesWebsiteService;
		@RequestMapping(value="/RelevantEnterprisesWebsiteEdit",method= RequestMethod.GET)
		public String update0(int websiteid ,Model  model){
			    model.addAttribute("websiteid", websiteid);
				return "RelevantEnterprisesWebsiteEdit";
				// TODO: handle exception
			
		}


		@RequestMapping(value="/RelevantEnterprisesWebsiteEdit",method= RequestMethod.POST)
		public String update(
				 String websiteid,String websitename, String websiteaddress){
			int id = Integer.parseInt(websiteid);
			Date edittime = new Date();
				RelevantEnterprisesWebsiteService.update(id,websitename, websiteaddress);
				return "RelevantEnterprisesWebsiteIndex";
		}

		@RequestMapping(value="/RelevantEnterprisesWebsiteInsert",method= RequestMethod.POST)
		public String Insert(RelevantEnterprisesWebsite RelevantEnterprisesWebsite) throws ParseException{
		    System.out.println(123);
			    System.out.println(RelevantEnterprisesWebsite);
			try {		
			    RelevantEnterprisesWebsiteService.Insert(RelevantEnterprisesWebsite);
				return "RelevantEnterprisesWebsiteIndex";
			} catch (Exception e) {
				return "RelevantEnterprisesWebsiteInsert";
				// TODO: handle exception
			}
			
		}
		@RequestMapping(value="/RelevantEnterprisesWebsiteInsert",method= RequestMethod.GET)
		public String Insert(){

				return "RelevantEnterprisesWebsiteInsert";
				// TODO: handle exception
			
			
		}
		@RequestMapping(value="/RelevantEnterprisesWebsite",method= RequestMethod.GET)
		public String Insert22(){

				return "RelevantEnterprisesWebsite";
				// TODO: handle exception
			
			
		}
		@RequestMapping(value="/RelevantEnterprisesWebsiteDelete",method= RequestMethod.GET)
		public String delete(int websiteid){
			try {
			    RelevantEnterprisesWebsiteService.delete(websiteid);
				return "forward:/fun2-relevantEnterpriseWebsite.html";
			} catch (Exception e) {
				return "RelevantEnterprisesWebsiteInsert";
				// TODO: handle exception
			}
			
		}

		@RequestMapping(value="/RelevantEnterprisesWebsiteIndex",method= RequestMethod.POST)
		public String IndexPost(){

				return "RelevantEnterprisesWebsiteIndex";
				// TODO: handle exception
			}
			


		@RequestMapping(value="/RelevantEnterprisesWebsiteIndex",method= RequestMethod.GET)
		@ResponseBody
		public Page InsertGet(@RequestParam(name="cur", defaultValue="1") int cur, Model model){
			Page page = RelevantEnterprisesWebsiteService.getRelevantEnterprisesWebsite(cur);
			System.out.println(page);
		 	model.addAttribute("page", page);
			
			

				return page;
				// TODO: handle exception
			
			
		}

			
		}



